package com.asia.db;

import java.sql.ResultSet;  
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;  
  
public class dbdemo {  
  
    static String sql = null;  
    static DBHelper db1 = null;  
    static ResultSet ret = null;  
      
  
    public static   List<String>  querytest() {  
        sql = "select * from TF_F_USER";
        db1 = new DBHelper(sql);//创建DBHelper对象  
        List<String> resultList= new ArrayList<String>();
        try {  
            ret = db1.pst.executeQuery();//执行语句，得到结果集  
            while (ret.next()) {  
                String userId = ret.getString(1);  
                String userName = ret.getString(2);  
                String phoneNumber = ret.getString(3);  
                String udate = ret.getString(4);  
                String res = userId + "\t" + userName + "\t" + phoneNumber + "\t" + udate;
              //  System.out.println( res);  
                resultList.add(res);
            }//显示数据  
            ret.close();  
            db1.close();//关闭连接  
        } catch (SQLException e) {  
            e.printStackTrace();  
        }  
        return resultList;
    }
    
    public static void main(String args[]){
    	List<String> al = querytest();
    	for (int i=0 ;i<al.size(); i++){
    		System.out.println(al.get(i));
    	}
    	
    	
    }
}  